#include "campo.h"

CampoForca::CampoForca (MODEL *pModel)
{
    FF_A=(pModel->FF_A);
    FF_B=(pModel->FF_B);
    FF_C=(pModel->FF_C);
    FF_Range=(pModel->FF_Range);
}
void CampoForca::ForcaResSS( SPHERE* s, SPHERE* t )
{

	REAL Dist2, Norm[2], Vrel[2];

	Norm[0] = t->R[0] - s->R[0];
	Norm[1] = t->R[1] - s->R[1];
	Dist2 = DOT( Norm, Norm );
	if (Dist2 <= FF_Range * FF_Range) {

		Vrel[0] = t->V[0] - s->V[0];
		Vrel[1] = t->V[1] - s->V[1];
		REAL FF = ( FF_A / sqrt(Dist2) - FF_B - FF_C * DOT(Vrel,Norm) ) / Dist2;	// F = A/R^2 -B/R - CV

		s->Force( -FF, Norm );
		t->Force( FF, Norm );
	}
}
